
#include "NetIO.h"

int NetIO::async_read( Socket handle, DataBlock *data_block, void *act, Reactor *reactor )
{
	return reactor->async_read( handle, data_block, act );
}

int NetIO::async_write( Socket handle, DataBlock *data_block, void *act, Reactor *reactor )
{
	return reactor->async_write( handle, data_block, act );
}

int NetIO::async_accept( Socket listen_handle, void *act, Reactor *reactor )
{
	return reactor->async_accept( listen_handle, act );
}

int NetIO::async_connect( const string &ip, short port, void *act, Reactor *reactor )
{
	return reactor->async_connect( ip, port, act );
}

void NetIO::async_cancel( Socket handle, Reactor *reactor )
{
	reactor->cancel_handle( handle );
}

int NetIO::async_operation_result( EventHandle &handle, DataBlock *& data_block,
                                   int &bytes_trans, int &errcode, void * &act,
                                   Reactor *reactor )
{
	Operation_Result result;
	reactor->operation_result( result );
	handle = result.handle_;
	data_block = result.data_block_;
	bytes_trans = result.bytes_transferred_;
	errcode = result.errcode_;
	act = result.act_;
	return 0;
}

int NetIO::async_operation_result( Operation_Result &result, Reactor *reactor )
{
	return reactor->operation_result( result );
}
